package com.hou.serviceuserfeign.config;

import com.hou.serviceuserfeign.feign.OrderFeignClient;
import com.hou.serviceuserfeign.po.Order;
import feign.hystrix.FallbackFactory;

/**
 * 使用继承FallbackFactory方式,使用fallback
 * 泛型为需要使用fallback的feign接口
 */
public class OrderFeignFallback implements FallbackFactory<OrderFeignClient> {
    @Override
    public OrderFeignClient create(Throwable throwable) {
        return new OrderFeignClient() {
            @Override
            public String getOrderName() {
                return "服务无效";
            }

            @Override
            public Order insertOrder(Order order) {
                return new Order("-1","服务挂了");
            }
        };
    }
}
